package com.example.demo.mapper;

import com.example.demo.pojo.Book;
import com.example.demo.pojo.request.BaseRequest;
import com.example.demo.pojo.request.BookRequest;
import com.example.demo.pojo.request.UserPageRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookMapper {

    //查询全部
    List<Book> list();

    //分页
    List<Book> page(BookRequest request);

    //添加
    @Insert("insert into library.book (name,description,publish_date,author,publisher,category,book_no,cover,create_time,score) values" +
            " (#{name}, #{description}, #{publishDate}, #{author}, #{publisher}, #{category},#{bookNo},#{cover},#{createTime},#{score})")
    void save(Book Book);

    //查找
    @Select("select * from library.Book where id=#{id}")
    Book getUser(Integer id);

    //更新
    @Update("update library.Book set name=#{name},description=#{description},publish_date=#{publishDate},author=#{author},publisher=#{publisher} " +
            ",category=#{category},book_no=#{bookNo},cover=#{cover},update_time=#{updateTime},score=#{score} where id=#{id}")
    void getUserByID(Book Book);

    //删除
    @Delete("delete from library.Book where id=#{id}")
    void delete(Integer id);
}
